﻿package mortal.game.view.flowerSend.panel
{
    import Message.Game.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.flowerSend.data.*;
    import mortal.mvc.core.*;

    public class FlowerReceivedBaseWin extends Window
    {
        private var _data:SFlowerInfoMsg;
        private var _showTween:TweenMax;
        private var _name:GTextFiled;
        private var _flower:GTextFiled;
        private var _sendBtn:GLoadingButton;
        private var _chatBtn:GLoadingButton;
        private var _kissBackBtn:GLoadingButton;
        private var _bg:GImageBitmap;
        private var _flowerIcon:GImageBitmap;

        public function FlowerReceivedBaseWin()
        {
            this.layer = LayerManager.windowLayer;
            this.setSize(433, 450);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this._bg = UIFactory.gImageBitmap("", 0, -20, this);
            this._flowerIcon = UIFactory.gImageBitmap("", 35, 300, this);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.FlowerTxt_1, 80, 105, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.FlowerTxt_2, 80, 165, this));
            var _loc_1:* = GlobalStyle.textFormatHuang2;
            _loc_1.size = 14;
            this._name = UIFactory.gTextField("", 25, 103, 200, 25, this, _loc_1.center());
            this._flower = UIFactory.gTextField("", 110, 130, 200, 25, this, _loc_1);
            this._sendBtn = UIFactory.gLoadingButton(ResFileConst.FlowerRebateBtn, 100, 200, 84, 73, this);
            this._sendBtn.drawNow();
            this._sendBtn.configEventListener(MouseEvent.CLICK, this.clickHandler);
            this._chatBtn = UIFactory.gLoadingButton(ResFileConst.FlowerChatBtn, 180, 250, 84, 73, this);
            this._chatBtn.drawNow();
            this._chatBtn.configEventListener(MouseEvent.CLICK, this.clickHandler);
            this._kissBackBtn = UIFactory.gLoadingButton(ResFileConst.FlowerKissBtn, 260, 200, 84, 73, this);
            this._kissBackBtn.drawNow();
            this._kissBackBtn.configEventListener(MouseEvent.CLICK, this.clickHandler);
            this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg.dispose(param1);
            this._bg = null;
            this._flowerIcon.dispose(param1);
            this._flowerIcon = null;
            this._name.dispose(param1);
            this._name = null;
            this._flower.dispose(param1);
            this._flower = null;
            this._sendBtn.dispose(param1);
            this._sendBtn = null;
            this._chatBtn.dispose(param1);
            this._chatBtn = null;
            this._kissBackBtn.dispose(param1);
            this._kissBackBtn = null;
            if (this._showTween != null)
            {
                this._showTween.kill();
                this._showTween = null;
            }
            this._data = null;
            return;
        }// end function

        public function set data(param1:SFlowerInfoMsg) : void
        {
            this._data = param1;
            var _loc_2:* = new ItemData(this._data.itemCode);
            this._bg.imgUrl = "FlowerSendBg_" + _loc_2.itemInfo.type;
            this._flowerIcon.imgUrl = "FlowerType_" + _loc_2.itemInfo.type + "_" + _loc_2.itemInfo.itemLevel;
            this._name.text = this._data.anonymous ? (Language.getString(35291)) : (this._data.fromPlayer.name);
            this._flower.htmlText = ItemsUtil.getItemWholeName(_loc_2, true, 1, true);
            return;
        }// end function

        private function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:FlowerSendData = null;
            this.hide();
            switch(event.target)
            {
                case this._sendBtn:
                {
                    _loc_2 = new FlowerSendData();
                    _loc_2.toPlayer = this._data.fromPlayer;
                    _loc_2.itemData = new ItemData(this._data.itemCode);
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FlowerOpenWin, _loc_2));
                    break;
                }
                case this._chatBtn:
                {
                    if (this._data.anonymous)
                    {
                        return MsgManager.showRollTipsMsg(Language.getString(35292));
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChatPrivate, this._data.fromPlayer));
                    break;
                }
                case this._kissBackBtn:
                {
                    if (this._data.anonymous)
                    {
                        return MsgManager.showRollTipsMsg(Language.getString(35292));
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FlowerKissBack, this._data.fromPlayer.name));
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ChatPrivateSend, {content:Language.getString(35293), toPlayer:this._data.fromPlayer, color:"0xfdfdfd"}));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show(param1, param2);
            this.scaleX = 0.5;
            this.scaleY = 0.5;
            if (this._showTween != null)
            {
                this._showTween.kill();
            }
            this._showTween = TweenMax.to(this, 0.5, {scaleX:1, scaleY:1, ease:Back.easeOut});
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            GameController.flowerSend.showNextFlowerWin();
            return;
        }// end function

        override protected function updateBtnSize() : void
        {
            if (_closeBtn)
            {
                _closeBtn.x = this.width - _closeBtn.width - 75;
                _closeBtn.y = 20;
            }
            return;
        }// end function

    }
}
